// 初始样式
require('../../assets/css/index.less');
require('../../assets/css/basic.less');
// 小图标
require('../../assets/fonts/iconfont.css');
require('../../assets/font/iconfont.css');
// 引入weui
require("../../lib/weui/weui.css");
const { default: axios } = require('axios');
var weui = require("../../lib/weui/weui.js");
// 当前页面样式
require('./courseint.less');
// 工具函数 utils
const dom = require('../../utils/dom');
const https = require('../../utils/https');
const local = require('../../utils/local');

dom.ready(function() {

    dom.addEvent(".back", "click", function() {
        history.go(-1)
    });

    // 渲染
    var id = location.search;
    https.get(`/api/train/courseDetail${id}`, function(res) {
        // console.log(res);
        var { errno, data } = res
        if (errno == 0) {
            console.log(data);
            dom.getEle(".name").innerHTML = data.name;
            dom.getEle(".calorie").innerHTML = data.calorie;
            dom.getEle(".time").innerHTML = data.time;
            dom.getEle(".peoplenum").innerHTML = data.peoplenum;
            dom.getEle(".desc").innerHTML = data.desc;
            dom.getEle(".frequency").innerHTML = data.frequency;
            dom.getEle(".instrument").innerHTML = data.instrument;
            //
            dom.getEle(".beginBtn").setAttribute("data-id", data.courseId);
            local.set("video", data.fragments);

        }

    });






    dom.addEvent(".beginBtn", "click", function(e) {

        var id = e.target.dataset.id
        console.log(id);
        location.href = "./coursetrain.html?id=" + id;
    });
})